<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
  <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>


</head>
<body>
<div id="app">
  <input type="text" v-model="message">
  <p>首字母大写:  {{message | capitalize | strrepeat(2) }} </p>
</div>
<script>
  new Vue({
    el: '#app',
    data(){
      return {
        message: 'shelley'
      }
    },
    filters: {
      capitalize: function (value){
        if(!value)return '';
        value = value.toString();
        return value.charAt(0).toUpperCase() + value.slice(1)
      },
      strrepeat: function (value, times) {
        if(typeof times === 'number' && !isNaN(times)) {
          let oldValue = value;
          for(var i=0; i<times; i++) {
            value += oldValue;
          }
        }
        return value;
      }
    }
  })
</script>

</body>
</html>